import { devtools, persist, subscribeWithSelector } from "zustand/middleware";
import { create } from "zustand";
import { immer } from "zustand/middleware/immer";
import {getRolesList} from '@/api'

const initialState = {

        rolesList:[]

};

export const rolesStore = create(
    immer(
        devtools(
            subscribeWithSelector(
                persist(() => initialState, {
                    name: "role-store",
                })
            )
        )
    )
);

export const getRolesListFromApi=async()=>{
   const res=await getRolesList();
   rolesStore.setState((state)=>{
    state.rolesList = res.docs
   })
}
